<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
    <title><%- (blocks[block] || '').replace(/\//g, ' - ') %></title>
    <link rel='stylesheet' href='<%- rootUrl %>/res/adapter.css' />
    <link rel='stylesheet' href='<%- rootUrl %>/node_modules/font-awesome/css/font-awesome.min.css' />
    <style>
        .fa {cursor:unset}
        .article-list { margin:0 0 12px 0 }
        .article-list > div:first-child b, .appends-list > div:first-child b {color:#19334d}
        .article-list > div { border-bottom:1px solid gainsboro;padding:12px 0;margin:0 12px }
        .article-list > div:first-child, .article-list > div:last-child { border-bottom:0 }
        .article-list > div > a > p:last-child { color:dimgrey; font-size:13px }
        .article-list > div img { max-height:120px; margin-right:3px; max-width: 100% }
        .article-list > div > p:last-child { color:darkgrey; font-size:11px }
        .appends-list { border:1px solid gainsboro }
        .appends-list > div { padding:9px 12px }
        .appends-list > div:not(:first-child) {font-size:15px;text-indent:0.5em}
        .appends-list a {color:#3e62a6}
        .appends-list a:hover {color:#0000ee}
        .common-style input[type="datetime-local"] {width:12.5em}
    </style>
    <script src="<%- rootUrl %>/node_modules/jquery/dist/jquery.min.js"></script>
    <script src="<%- rootUrl %>/res/adapter.js"></script>
</head>
<body class="body-nomargin">
<alljs-widget><message-top><%- message %></message-top></alljs-widget>
<%- components['signhead'] ? include(components['signhead'], this) : '' %>
<div class="width-limit">
    <div class="padding-leftright">
        <form class="common-style adapt-panel" style="align-items:center; margin-top:12px;color:dimgrey;font-size: 12px">
            <div>
                <div style="display:inline-block;position:relative">
                    <button class="button-likeText" type="submit" style="position:absolute;right:8px;top:0.5em;padding:5px 9px;background:white"><i class="fa fa-search"></i></button>
                    <input name="text" type="search" value="<%= text %>" placeholder="搜一下" style="vertical-align:unset" />
                </div>
                <span style="margin-right:0.5em">发布时间<i class="fa fa-chevron-down" style="cursor:pointer" onclick="showTimefilter(this)"></i></span>
            </div>
            <div style="display:none">从<input name="fromtime" type="datetime-local" value="<%= fromtime %>"/></div>
            <div style="display:none">到<input name="totime" type="datetime-local" value="<%= totime %>"/></div>
        </form>
        <h2>文章搜索结果</h2>
    </div>
    <div class="adapt-panel">
        <div class="adapt-two-left article-list">
            <div class="adapt-panel"><b style="flex-grow:1"><i class="fa fa-bars"></i>&nbsp;搜索列表</b><button onclick="location.href='./articlepublic.html'" style="margin-right:6px"><i class="fa fa-plus" style="color:green"></i> 新文章</button><button onclick="location.href='./articlereproduce.html'"><i class="fa fa-share" style="color:royalblue"></i> 转载</button></div>
            <% for (let article of articles) { %>
            <div>
                <a href="./article?id=<%- article._id %>">
                    <p><% if(article.badge){ %><span class="badge" style="background-color:<%- article.badge.color %>"><%- article.badge.text %></span><% } %><%- article.title %></p>
                    <p><%- article.brief %></p>
                </a>
                <% if (article.briefImages != null && article.briefImages.length > 0) { %>
                <div><% for (let i=0; i < Math.min(article.briefImages.length, 3); i++) { %><img src="<%- article.briefImages[i] %>" /><% } %></div>
                <% } %>
                <p class="adapt-panel"><span style="flex-grow:1"><%- article.author?article.author+' &nbsp; ':'' %><%- article.publish?article.publish+' &nbsp; ':'' %>发布人:<%- article.produceUser.nickname %></span>
                    <span>
                    <% if(isAdmin && (blockRoot==='' || article.mainclass.substr(0,block.length)===block)){ %>
                    <button class="button-likeText" onclick="forbit('<%- article._id %>')" <%- article.status===1?'style="color:red"':'' %>/><i class="fa fa-ban"></i></button>
                        <button class="button-likeText" onclick="promote('<%- article._id %>', '<%- article.popular<100000000 %>')" <%- article.popular>=100000000?'style="color:red"':'' %>><i class="fa fa-arrow-up"></i></button>
                        &nbsp;
                    <% } %>
                    <i class="fa fa-thumbs-up"></i> <%- article.fonds %> &emsp;<i class="fa fa-comment"></i> <%- article.replys %>
                </span>
                </p>
            </div>
            <% } %>
        </div>
        <div class="adapt-two-right" style="padding:0 6px 6px 6px">
            <%- include('com.userpanel.html', this) %>
            <div class=" appends-list" style="margin-top:24px">
                <div><b><i class="fa fa-th-large"></i>&nbsp;网站功能</b></div>
                <div><a href="./chat.html"><span>板块聊天室</span></a></div>
                <div><a href="./chat.html?channel="><span>自建聊天室</span></a></div>
            </div>
            <div class=" appends-list" style="margin-top:24px">
                <div><b><i class="fa fa-globe"></i>&nbsp;Alljs子站</b></div>
                <div><a href="/alljs/"><span>Alljs社区</span></a></div>
                <div><a href="/funs/"><span>老爸老妈快乐站</span></a></div>
                <div><a href="/babyedu/"><span>祖国的花朵栽培网</span></a></div>
                <div><a href="/econexam/"><span>经济类职业考试网</span></a></div>
                <div><a href="/dd/"><span>尽职调查</span></a></div>
                <div><a href="/mili/"><span>军武爱好者</span></a></div>
                <div style="color:dimgrey">想建站的请联系：15920372250 (何先生)</div>
            </div>
            <% if (blockRoot==='' || blockRoot=='alljs'){ %>
            <div class=" appends-list" style="margin-top:24px">
                <div><b><i class="fa fa-external-link-square"></i>&nbsp;友情链接</b></div>
                <div><a href="javascript:window.open('https://github.com/')" ><span>Github</span></a></div>
                <div><a href="javascript:window.open('https://sourceforge.net/')" ><span>SourceForge</span></a></div>
                <div><a href="javascript:window.open('https://stackoverflow.com/')" ><span>Stack Overflow</span></a></div>
                <div><a href="javascript:window.open('https://msdn.microsoft.com/library/')" ><span>MSDN</span></a></div>
                <div><a href="javascript:window.open('https://www.npmjs.com/')" ><span>NPM</span></a></div>
                <div><a href="javascript:window.open('http://www.w3school.com.cn/')" ><span>W3school</span></a></div>
                <div><a href="javascript:window.open('https://www.runoob.com/')" ><span>菜鸟教程</span></a></div>
                <div><a href="javascript:window.open('https://www.csdn.net/')" ><span>CSDN</span></a></div>
                <div><a href="javascript:window.open('https://www.oschina.net/')" ><span>开源中国</span></a></div>
                <div><a href="javascript:window.open('https://www.bootcdn.cn/')" ><span>BootCDN</span></a></div>
                <div><a href="javascript:window.open('https://www.javascriptcn.com/')" ><span>JavaScript中文网</span></a></div>
                <div><a href="javascript:window.open('https://segmentfault.com/')" ><span>SegmentFault思否</span></a></div>
                <div><a href="javascript:window.open('http://ourjs.com/')" ><span>OurJS社区</span></a></div>
                <div><a href="javascript:window.open('https://www.bootcss.com/p/layoutit/')" ><span>layoutit</span></a></div>
            </div>
            <% } %>
        </div>
    </div>
</div>
<% if(isAdmin){ %>
<script>
    function showTimefilter(sender){
        let isshow = sender.classList.contains('fa-chevron-down');
        sender.parentNode.parentNode.parentNode.querySelectorAll('div:not(:first-child)').forEach(dom => dom.style.display = (isshow?'':'none'));
        sender.classList.remove(isshow ? 'fa-chevron-down' : 'fa-chevron-up');
        sender.classList.add(isshow ? 'fa-chevron-up' : 'fa-chevron-down');
    }
    function forbit(id){
        window.postRequest('./deleteSomething', {col:'article',type:'forbid',filter:'{"_id":"'+id+'"}'});
    }
    function promote(id, isPromote){
        isPromote = isPromote === 'true';
        window.postRequest('./articlePromote', {type:(isPromote ? 'promote' : 'demote'),id});
    }
</script>
<% } %>
</body>
</html>